<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ page import = "java.sql.*, java.util.*" %>
<% request.setCharacterEncoding("euc-kr"); %>
<jsp:include page="header.jsp"/>

<jsp:include page="aside_customer.jsp"/>
<%
	int num = Integer.parseInt(request.getParameter("num"));

	String name = request.getParameter("name");
	String pass = request.getParameter("pass");
	String email = request.getParameter("email");
	String title = request.getParameter("title");
	String contents = request.getParameter("contents");
	
	Class.forName("com.mysql.jdbc.Driver");
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	
	try{
		String jdbcDriver = "jdbc:mysql://192.168.0.120:3306/coffee?"
				+ "useUnicode=true&characterEncoding=euckr";
		String dbUser = "root";
		String dbPass = "123456";
	
		
		conn = DriverManager.getConnection(jdbcDriver, dbUser, dbPass);
		
		Calendar dateIn = Calendar.getInstance();
		String indate = Integer.toString(dateIn.get(Calendar.YEAR)) + "-";
		indate = indate + Integer.toString(dateIn.get(Calendar.MONTH)+1) + "-";
		indate = indate + Integer.toString(dateIn.get(Calendar.DATE)) + " ";
	
		
		String strSQL =
		"update RVboard set name=?, pass=?, email=?, title=?," +
		"contents=?, writedate=? where num=?";
		
		pstmt = conn.prepareStatement(strSQL);
		
		pstmt.setString(1, name);
		pstmt.setString(2, pass);
		pstmt.setString(3, email);
		pstmt.setString(4, title);
		pstmt.setString(5, contents);
		pstmt.setString(6, indate);
		pstmt.setInt(7, num);
		pstmt.executeUpdate();
		
		response.sendRedirect("listboard.jsp");
	}catch(SQLException ex){
		out.println(ex.getMessage());
	}finally{
		if(pstmt != null) try{pstmt.close();} catch(SQLException ex){}
		if(conn != null) try{conn.close();} catch(SQLException ex){}
	}
	
%>